home *** CD-ROM | disk | FTP | other *** search
- Path: news.halcyon.com!usenet
- From: normanb@halcyon.com (Norm Bryar)
- Newsgroups: comp.lang.c++
- Subject: Re: Classes in DLL's
- Date: Sat, 20 Jan 1996 00:47:35 GMT
- Organization: Northwest Nexus Inc.
- Message-ID: <4dpe2g$63d@news.halcyon.com>
- References: <4dotif$1dkc@rtpnews.raleigh.ibm.com>
- NNTP-Posting-Host: blv-pm10-ip8.halcyon.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- jtoering@vnet.ibm.com wrote:
-
- >I am familiar with how to import functions from
- >DLL's but how do you import class methods?
-
- >thanks
-
- >Jim T
-
- Generally, use an import library.
- Don't expect DLLs and EXEs made by different compilers to name-mangle
- identically; a DLL made with Borland C++ may not dynalink well to a
- MSVC executable.
-
- GetProcAddress() on class methods is problematic; you need to know the
- 'decorated' (mangled) name, you're pretty much restricted to static
- methods, etc. You can still late-bind to the DLL, however, by using
- GetProcAddress() on a 'C' style function that returns a pointer to an
- object instance. Then use the pointer like you would any other.
-
- Then there's COM, the Ole-style interfaces.
-
- Hope this helps.
- --Norm
-
- ///////////////////////
- mydll.h
- #define EXPORT __declspec(dllexport)
- class myclass
- {
- EXPORT myclass();
- EXPORT virtual ~myclass();
- EXPORT virtual save( CArchive & archive ) const;
- ...
- };
- // for late-binding fans...
- extern "C" EXPORT myclass * CreateInstance( void );
-
- mydll.mak
- /IMPLIB:mydll.lib ; for early-binding fans
-
- myexe.cpp
- #include<mydll.h>
- ...
-
- myexe.mak
- /LIB: mydll.lib
-
-
-
-